package com.learn.algorithm_461;

/**
 * 461. 汉明距离
 *      两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目
 * https://leetcode-cn.com/problems/hamming-distance/
 *
 * @author gatts, 2020/8/23 13:21
 */
public class Solution {

    public static int hammingDistance(int x, int y) {
        return Integer.bitCount(x ^ y);
    }

    public static void main(String[] args) {
        //- 0101
        int x = 5;
        //- 1001
        int y = 9;
        System.out.println("5和9的汉明距离：2");
        System.out.println(hammingDistance(x, y));
    }

}
